﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using YAXLib;
using RaytracerLib.MathLib;
using System.Drawing;

namespace RaytracerLib.Samplers
{
    public abstract class LowDiscrepancySequenceSampler : NonUniformSampler
    {
        [YAXNode]
        public int Subresolution = 3;

        public override IEnumerable<Vector2> GetSamples(Rectangle a_rect)
        {
            int samples_x = a_rect.Width * Subresolution;
            int samples_y = a_rect.Height * Subresolution;

            for (int y = 0; y < samples_y; y++)
            {
                for (int x = 0; x < samples_x; x++)
                {
                    Vector2 sample = NextSample();
                    yield return new Vector2(
                        a_rect.Left + sample.X * a_rect.Width,
                        a_rect.Top + sample.Y * a_rect.Height);
                }
            }
        }

        protected abstract Vector2 NextSample();
    }
    }
